home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / quikc21.zip / QINITEST.C < prev    next >
Text File  |  1989-07-06  |  15KB  |  398 lines

  1. /*===========================================================================*\
  2. | QINITEST.C                                               ver 2.1, 07-06-89  |
  3. |                                                                             |
  4. | Tests your system configuration                                             |
  5. |                                                                             |
  6. |  Copyright (c) 1988,1989 by James H. LeMay, All rights reserved.            |
  7. |                                                                             |
  8. |  Conversion to C by Jordan Gallagher / Wisdom Research                      |
  9. \*===========================================================================*/
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <conio.h>
  14. #include <string.h>
  15. #include <dos.h>
  16.  
  17. #include "qwikc21.h"
  18.  
  19. /* un-comment the line below to include IBM's submodel ID detection */
  20. /* #define ADD_SUBMODEL */
  21.  
  22. char newmode, oldmode;
  23. char strng[80];
  24. char ch;
  25. int cursor_delay=1500;
  26.  
  27. #ifndef __TURBOC__
  28. union REGS mr;
  29. #define textmode(m)     { mr.h.ah=0; mr.h.al=m; int86(0x10,&mr,&mr); }
  30. #endif
  31.  
  32.  
  33. /******************************| check_zenith |*****************************\
  34. Since Zenith doesn't have snow on any CGAs, turn off snow checking.
  35. \***************************************************************************/
  36. void check_zenith(void)
  37. {
  38.     char tmp[10];
  39.  
  40.     movedata( 0xF000u, 0x800Cu, (unsigned)(((char far *)tmp)+1),
  41.                                 (unsigned)((char far *)tmp),     8 );
  42.     if(qsnow && (strncmp( tmp, "ZDS CORP", 8 )) == 0) {
  43.         qsnow=0;
  44.         cardsnow=0;
  45.     }
  46. }
  47.  
  48.  
  49. /********************************| clearscr |*******************************\
  50. Clears the screen using the yellow on blue attribute.
  51. \***************************************************************************/
  52. void clearscr(void)
  53. {
  54.     qfill( 1, 1, crt_rows, crt_cols, YELLOW+BLUE_BG, ' ' );
  55. }
  56.  
  57.  
  58. /*********************************| init |***********************************\
  59. Initializes by checking for Zenith and clearing the screen.
  60. \****************************************************************************/
  61. void init(void)
  62. {
  63.     qreinit();
  64.     check_zenith();
  65.     setmultitask();
  66. #ifdef __TURBOC__
  67.     if(inmultask) directvideo=0;
  68. #endif
  69.     clearscr();
  70. }
  71.  
  72.  
  73. /********************************| btoa |************************************\
  74. Converts a long to a string.  The target string contains the long in
  75. binary form, i.e. "10100101101101010010010110110101".
  76. The parameter bitcnt specifies the number of bits to be processed.
  77. The return value is a pointer to the target string.
  78. \****************************************************************************/
  79. char *btoa( long val, char bitcnt, char *string )
  80. {
  81.     char bit;
  82.  
  83.     for(bit=0; bit < bitcnt; bit++) {
  84.         string[bit] = ((val >> bit) & 1) + 48;
  85.     }
  86.     string[bit]=0;
  87.  
  88.     return(string);
  89. }
  90.  
  91.  
  92. /********************************| htoa |************************************\
  93. Converts a long to a string.  The target string contains the long in
  94. hexadecimal form, i.e. "21CF89A5".
  95. The parameter hcnt specifies the amount of characters the target
  96. string should contain.
  97. The return value is a pointer to the target string.
  98. \****************************************************************************/
  99. char *htoa( long val, char hcnt, char *string )
  100. {
  101.     if(hcnt > 4)
  102.         sprintf( string, "0x%*lX", hcnt, val );
  103.     else
  104.     if(hcnt > 2)
  105.         sprintf( string, "0x%0*X", hcnt, (int) val );
  106.     else
  107.     if(hcnt <= 2)
  108.         sprintf( string, "0x%0*hX", hcnt, (unsigned char) val );
  109.  
  110.     return(string);
  111. }
  112.  
  113.  
  114. /*********************************| stryn |**********************************\
  115. Places the string "YES" or "NO" in the str parameter based on whether
  116. the specified int is 1 or 0.
  117. \****************************************************************************/
  118. char *stryn( int val, char *str )
  119. {
  120.     return(strcpy( str, val ? "YES" : "NO" ));
  121. }
  122.  
  123.  
  124. /******************************| display_dev |*******************************\
  125. Sets the global variable "strng" based on the specified display device's
  126. number.
  127. \****************************************************************************/
  128. void display_dev( char dd )
  129. {
  130.     switch(dd) {
  131.         case 0x00: strcpy( strng, "No display" );                  break;
  132.         case 0x01: strcpy( strng, "MDA with 5151 monochrome" );    break;
  133.         case 0x02: strcpy( strng, "CGA with 5153/4 color" );       break;
  134.         case 0x04: strcpy( strng, "EGA with 5153/4 color" );       break;
  135.         case 0x05: strcpy( strng, "EGA with 5151 monochrome" );    break;
  136.         case 0x06: strcpy( strng, "PGC with 5175 color" );         break;
  137.         case 0x07: strcpy( strng, "VGA with analog monochrome" );  break;
  138.         case 0x08: strcpy( strng, "VGA with analog color" );       break;
  139.         case 0x0B: strcpy( strng, "MCGA with analog monochrome" ); break;
  140.         case 0x0C: strcpy( strng, "MCGA with analog color" );      break;
  141.         default:   strcpy( strng, "Reserved" );
  142.     }
  143. }
  144.  
  145.  
  146. /*****************************| do_setcursor |*******************************\
  147. Calls setcursor with the cursor parameter, and displays the specified
  148. message along with a hexadecimal version of the cursor word.
  149. \****************************************************************************/
  150. void do_setcursor( char *msg, unsigned cursor )
  151. {
  152.     char msg1[80],msg2[80];
  153.  
  154.     strcpy( msg1, msg );
  155.     htoa( (long) cursor, 4, msg2 );
  156.  
  157.     setcursor( cursor );
  158.     qwriteeos( SAMEATTR, strcat( msg1, msg2 ) );
  159.     gotoeos();
  160. #ifdef __TURBOC__
  161.     delay( cursor_delay );
  162. #else
  163.     suspend( cursor_delay );
  164. #endif
  165.     eosln();
  166. }
  167.  
  168.  
  169. /*****************************| do_modcursor |*******************************\
  170. Calls modcursor with the cursor parameter, and displays the specified
  171. message along with a hexadecimal version of the cursor's word after
  172. being set by modcursor.
  173. \****************************************************************************/
  174. void do_modcursor( char *msg, int cursor )
  175. {
  176.     char msg1[30],msg2[10],msg3[10];
  177.  
  178.     modcursor( cursor );
  179.     strcpy( msg1, msg );
  180.     htoa( (long) cursor, 4, msg2 );
  181.     htoa( (long) getcursor(), 4, msg3 );
  182.     strcat( msg1, msg2 );
  183.     strcat( msg1, " " );
  184.     strcat( msg1, msg3 );
  185.  
  186.     qwriteeos( SAMEATTR, msg1 );
  187.     gotoeos();
  188. #ifdef __TURBOC__
  189.     delay( cursor_delay );
  190. #else
  191.     suspend( cursor_delay );
  192. #endif
  193.     eosln();
  194. }
  195.  
  196.  
  197. /*******************************| waitkey |**********************************\
  198. Waits for a keypress, eliminating extra key-ahead if an extended key
  199. is pressed, generating an escape sequence.
  200. \****************************************************************************/
  201. void waitkey(void)
  202. {
  203.     qwrite( crt_rows, 1, SAMEATTR, "Press any key..." );
  204.     gotoeos();
  205.  
  206.     do ch=getch(); while(kbhit());
  207. }
  208.  
  209.  
  210. /*********************************| main |***********************************\
  211. The main block.
  212. \****************************************************************************/
  213. void main()
  214. {
  215.     char s[80];
  216.  
  217.     qinit();
  218.     init();
  219.  
  220.     oldmode=qvideo_mode;
  221.  
  222.     qwrite( 1, 1, SAMEATTR, "Which text mode (0,1,2,3,7) ? " );
  223.     gotoeos();
  224.  
  225.     while( strchr( "01237", (ch=getch()) )==NULL );
  226.     newmode=ch-'0';
  227.  
  228.     if(newmode != oldmode) {
  229.         textmode( newmode );
  230.         qreinit();
  231.     }
  232.  
  233.     init();
  234.  
  235.     switch( cpuid ) {
  236.         case cpu8086:  strcpy( strng, "Intel 8086/88"   ); break;
  237.         case cpu80186: strcpy( strng, "Intel 80186/188" ); break;
  238.         case cpu80286: strcpy( strng, "Intel 80286"     ); break;
  239.         case cpu80386: strcpy( strng, "Intel 80386"     ); break;
  240.     }
  241.  
  242.     qwrite( 1, 1, SAMEATTR, "CPU ident         = " );
  243.     qwriteeos( SAMEATTR, strng );
  244.  
  245. #ifdef ADD_SUBMODEL
  246.     get_submodel_id();           /* Check docs before using this function. */
  247. #endif
  248.  
  249.     switch(system_id) {
  250.         case 0xFF: strcpy( strng, "IBM PC"    ); break;
  251.         case 0xFE: strcpy( strng, "IBM PC